import java.awt.Color;
import java.awt.Component;
import java.awt.Font;

import javax.swing.JLabel;
import javax.swing.SwingConstants;

import java.awt.Rectangle;


public class Tile 
{
	private Color tileColor = Color.ORANGE;
	private int number = 2;
	private int x = 0;
	private int y = 0;
	private JLabel freshLabel = new JLabel("", SwingConstants.CENTER);
	private GameScreen object;
	private Location loc;
	
	
	public Tile(Color color, int num, int xCord, int yCord, GameScreen obj)
	{
		tileColor = color;
		object = obj;
		number = num;
		x = xCord;
		y = yCord;
		//Add tile to GUI
		freshLabel.setText("" + num);
		freshLabel.setFont(new Font("Stencil Std", Font.PLAIN, 20));
		freshLabel.setBounds(new Rectangle(x, y, 76, 76));
		freshLabel.setOpaque(true);
		
		freshLabel.setForeground(new Color(153, 102, 102));
		freshLabel.setBackground(color);
		obj.label.add(freshLabel);
		obj.repaint();

		//set Location for item
		int tempX = 0;
		int tempY = 0;
		switch (x)
		{
		case 10: tempX = 0;
		break;
		case 96: tempX = 1;
		break;
		case 180: tempX = 2;
		break;
		case 264: tempX = 3;
		}
		switch (y)
		{
		case 135: tempY = 0;
		break;
		case 220: tempY = 1;
		break;
		case 303: tempY = 2;
		break;
		case 387: tempY = 3;
		break;
		}
		loc = new Location(tempX, tempY);
	}
	public void removeTile()
	{
		object.label.remove(freshLabel);
	}
	public int getY()
	{
		return y;
	}
	public int getX()
	{
		return x;
	}
	public int getNum()
	{
		return number;
	}
	public Color getColor()
	{
		return tileColor;
	}
	public Location getLocation()
	{
		return loc;
	}
	public void setLocation(Location location)
	{
		switch (location.getRow())
		{
		case 0: x = 10;
		break;
		case 1: x = 96;
		break;
		case 2: x = 180;
		break;
		case 3: x = 264;
		break;
		}
		
		switch (location.getCol())
		{
		case 0: y = 135;
		break;
		case 1: y = 220;
		break;
		case 2: y = 303;
		break;
		case 3: y = 387;
		break;
		}
		//System.out.println("Row: " + location.getRow());
		//System.out.println(location.getCol());
		
		loc = location;
		freshLabel.setBounds(new Rectangle(x, y, 76, 76));
		object.repaint();
	}
}
